/**
 * Created by yangxu on 2017/10/21.
 */
import Vue from 'vue'

import  Config  from "@/conf/params.js";

import axios from 'axios';

export default {
  deleteFile({id,token}){

    return axios({
      url:`${Config.server}/v1/deleteFile`,
      method:'post',
      data:{
        id:id
      },
      headers: {
        "Authorization":"Bearer "+token
      }
    });

  },
  loadFile({data,token}){

    return axios({
      url:`${Config.server}/v1/upload`,
      method:'post',
      data:data,
      headers: {
        'Content-Type': 'multipart/form-data',
        "Authorization":"Bearer "+token
      }
    });

  },
  doCreateProject ({project,token}) {

    return axios({
      method:'post',
      url:`${Config.server}/v1/build/project`,
      data:project,
      headers:{
        "Authorization":"Bearer "+token
      }
    });

  },
  doEditProject({token,project}){

    var { project_manager,id,contract_time,jianli_name,apply_type,apply_complay,apply_user,file } = project;

    return axios({
      method:'post',
      url:`${Config.server}/v1/update/project`,
      data:{
        project_manager,id,contract_time,jianli_name,apply_type,apply_complay,apply_user,file
      },
      headers:{
        "Authorization":"Bearer "+token
      }
    });

  },
  doGetProject(token){
    return axios({
      method:'get',
      url:`${Config.server}/v1/getMyProject`,
      headers:{
        "Authorization":"Bearer "+token
      }
    });
  },
  doGetSingeProject({pId,token}){

    return axios({
      method:'post',
      url:`${Config.server}/v1/getBasicProject`,
      data:{
        id:pId
      },
      headers:{
        "Authorization":"Bearer "+token
      }
    });

  },
  doGetProgressPlan({ token,taskId,pId}){

    return axios({
      method:'post',
      url:`${Config.server}/v1/getProgressPlan`,
      data:{
        id:taskId,
        project_id:pId
      },
      headers:{
        "Authorization":"Bearer "+token
      }
    });

  },
  doGetProjectState({token,pId}){

    return axios({
      method:'post',
      url:`${Config.server}/v1/getDynamics`,
      data:{
        id:pId
      },
      headers:{
        "Authorization":"Bearer "+token
      }
    });

  },
  doAddProjectBuildPlan({token,id,project_id,users_id,branch_project}){

    return axios({
      method:'post',
      url:`${Config.server}/v1/makeTimePlan`,
      data:{
        id,
        project_id,
        users_id,
        branch_project
      },
      headers:{
        "Authorization":"Bearer "+token
      }
    });

  },
  getCheckPlanDetail (token, check_plan_id) {
    return axios({
      method:'post',
      url:`${Config.server}/v1/getCheckPlan`,
      data: {
        check_plan_id
      },
      headers:{
        "Authorization":"Bearer "+token
      }
    })
  },
  doSendCheckPlan({token,task_id,project_id,users_id,progress_plan_id,file,branch_son_project}){

    return axios({
      method:'post',
      url:`${Config.server}/v1/checkPlan`,
      data: {
        task_id,
        project_id,
        users_id,
        progress_plan_id,
        file,
        branch_son_project
      },
      headers:{
        "Authorization":"Bearer "+token
      }
    })
  },
  doModifyBuildPlan({token,task_id,file,project_id,users_id,check_plan_id,branch_son_project,cause}){
    return axios({
      method:'post',
      url:`${Config.server}/v1/make/newPlan`,
      data: {
        task_id,file,project_id,users_id,check_plan_id,branch_son_project,cause
      },
      headers:{
        "Authorization":"Bearer "+token
      }
    });

  },
  doGetTaskInfo({token,task_id}){
    return axios({
      method:'get',
      url:`${Config.server}/v1/getTaskInfo?id=${task_id}`,
      headers:{
        "Authorization":"Bearer "+token
      }
    });

  }
}
